function sendMessage(){
    var text1 = document.getElementById("input-box");
    var text2 = document.getElementById("summary-box");
    var text3 = document.getElementById("title-box");
    var wsData = 0.0;
    console.log(text1.value);

    function log(msg) {
        //text2.value =text2.value + msg;
        var json=eval(msg);
        text2.value = "";
        text3.value = "";
        var num = 1;
        for(var i=0;i<5;i++)
        {
            text3.value = text3.value + num +": " + json[0][i] + "\n";
            text2.value = text2.value +  num +": "  + json[1][i] + "\n";
            num = num + 1;
        }
        /*
        try{
          JSONArray jsonArray=new JSONArray(msg);
          for(int i=0;i<jsonArray.length(); i++)
          {
            JSONArray jsonArray1=jsonArray.getJSONArray(i);
            Log.e("jsonarray",jsonArray1.toString());
          }
        }catch (JSONException e)
        {
          e.printStackTrace();
        }*/
        //document.getElementById('log').textContent += msg + '\n';
    }
    // setup websocket with callbacks
    var ws = new ReconnectingWebSocket('ws://49.232.71.217:3000');
    ws.onopen = function() {
        //log('CONNECT');
        var sendData = replaceall(text1.value,"\n"," ");
        console.log(sendData);
        ws.send(sendData);
    };
    ws.onclose = function() {
        //log('DISCONNECT');
        ws.close();
    };
    ws.onmessage = function(event) {
        log('' + event.data);
        console.log(event.data);
    };

}

function replaceall(textval,a,b){
    var c=textval.length;
    for(var i=0;i<c;i++){
        textval=textval.replace(a,b);
    }
    return textval;
}
